package com.ruoyi.plant.service.impl;

import com.ruoyi.plant.domain.Plant;
import com.ruoyi.plant.mapper.PlantMapper;
import com.ruoyi.plant.service.PlantService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class PlantServiceImpl implements PlantService {

    @Autowired
    PlantMapper mapper;

    public static Logger log = LoggerFactory.getLogger(PlantServiceImpl.class);

    @Override
    public List<Plant> getPlantList(Plant p) {
        return mapper.getPlantList(p);
    }

    @Override
    public List<Plant> selectPlant(String p) { return mapper.selectPlant(p); }

    @Override
    public int addPlant(Plant p) { return mapper.addPlant(p); }

    @Override
    public int updatePlant(Plant p) { return mapper.updatePlant(p);}

    @Override
    public int deletePlantById(int id) { return mapper.deletePlantById(id);}


    @Override
    public List<Plant> selectPlantList2(Plant p) {
        List<Plant> result = mapper.selectPlantList2(p);
        if (result.size() <= 0) {
            log.error("没有查询到任何植物");
        }else {
            log.info("查询到了植物，查询到的是：" + result.get(0).getName());
        }
        return result;
    }


}
